//
//  SupportBankListViewController.m
//  WBBaseProject
//
//  Created by xiaozhi on 2018/4/4.
//  Copyright © 2018年 吴斌. All rights reserved.
//

#import "SupportBankListViewController.h"
#import "SupportBankChildController.h"

#define BOTTOM 60

@interface SupportBankListViewController ()

@property (nonatomic, strong) UIView *redView;
@property (nonatomic, strong) UIView *lineView;

@end

@implementation SupportBankListViewController

- (UIView *)redView {
    if (!_redView) {
        _redView = [[UIView alloc] initWithFrame:CGRectZero];
        _redView.backgroundColor = [UIColor colorWithRed:168.0/255.0 green:20.0/255.0 blue:4/255.0 alpha:1];
    }
    return _redView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    if (self.menuViewStyle == WMMenuViewStyleTriangle) {
        [self.view addSubview:self.redView];
    }
    
    self.title = @"支持银行卡";
    
    self.view.backgroundColor = [UIColor colorWithRed:239.0/255.0 green:239.0/255.0 blue:239.0/255.0 alpha:1];
    //[self lineView];
    [self addNavBtn];
}
- (void)addNavBtn{
    //返回按钮
    UIButton *btn = [Factory backButton:self];
    [btn addTarget:self action:@selector(clickBack:) forControlEvents:UIControlEventTouchUpInside];
    
}
- (UIView *)lineView {
    
    self.menuItemWidth = 80;
    
    if (!_lineView) {
        _lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
        _lineView.backgroundColor = [UIColor colorWithRed:239.0/255.0 green:239.0/255.0 blue:239.0/255.0 alpha:1];
        
        
        [self.menuView insertSubview:_lineView atIndex:0];
        
    }
    return _lineView;
}

- (void)clickBack:(id)sender{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    self.redView.frame = CGRectMake(0, CGRectGetMaxY(self.menuView.frame), self.view.frame.size.width, 2.0);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)numbersOfChildControllersInPageController:(WMPageController *)pageController {
    return 2;
}

- (NSString *)pageController:(WMPageController *)pageController titleAtIndex:(NSInteger)index {
    switch (index) {
        case 0: return @"储蓄卡";
        case 1: return @"信用卡";
            
    }
    return @"NONE";
}

- (UIViewController *)pageController:(WMPageController *)pageController viewControllerAtIndex:(NSInteger)index {
    switch (index) {
        case 0:
        {
            SupportBankChildController * vc = [[SupportBankChildController alloc]init];
            vc.type = 0;
            
            return vc;
        }
        case 1: {
            SupportBankChildController * vc = [[SupportBankChildController alloc]init];
            vc.type = 1;
            return vc;
        }
    }
    return [[UIViewController alloc] init];
}

- (CGFloat)menuView:(WMMenuView *)menu widthForItemAtIndex:(NSInteger)index {
    CGFloat width = [super menuView:menu widthForItemAtIndex:index];
    return width + 20;
}

- (CGRect)pageController:(WMPageController *)pageController preferredFrameForMenuView:(WMMenuView *)menuView {
    //    if (self.menuViewPosition == WMMenuViewPositionBottom) {
    //        menuView.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1.0];
    //        return CGRectMake(0, self.view.frame.size.height - 44, self.view.frame.size.width, 44);
    //    }
    CGFloat leftMargin = self.showOnNavigationBar ? 50 : 0;
    //CGFloat originY = self.showOnNavigationBar ? 0 : CGRectGetMaxY(self.navigationController.navigationBar.frame);
    
    return CGRectMake(leftMargin, 10, self.view.frame.size.width - 2*leftMargin, 60);
}

- (CGRect)pageController:(WMPageController *)pageController preferredFrameForContentView:(WMScrollView *)contentView {
    //    if (self.menuViewPosition == WMMenuViewPositionBottom) {
    //        return CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height - 64 - 44);
    //    }
    CGFloat originY = CGRectGetMaxY([self pageController:pageController preferredFrameForMenuView:self.menuView]);
    if (self.menuViewStyle == WMMenuViewStyleTriangle) {
        originY += self.redView.frame.size.height;
    }
    return CGRectMake(0, originY, self.view.frame.size.width, self.view.frame.size.height - originY);
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
